/**
 * DiggApiNet - Digg API .NET Wrapper
 * 
 * Author: Sean Hickey
 * Link: http://www.headzoo.com/digg_api_net
 * License: GPL v2 ( http://www.gnu.org/licenses/gpl.txt )
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Collections;

namespace DiggApiNet
{
    public class DiggContainers : DiggReturnBaseCollection
    {
        private List<DiggContainer> _containers;
        public List<DiggContainer> Containers
        {
            get
            {
                return _containers;
            }
            set
            {
                _containers = value;
            }
        }
        public DiggContainer this[int index]
        {
            get
            {
                return _containers[index];
            }
            set
            {
                _containers[index] = value;
            }
        }

        public DiggContainers()
        {
            _containers = new List<DiggContainer>();
        }
        public DiggContainers(XmlDocument xml_doc) : base(xml_doc, "containers")
        {
            _containers = new List<DiggContainer>();
            if (xml_doc.SelectSingleNode("containers") == null
                || xml_doc.SelectSingleNode("containers").SelectNodes("container") == null) {
                throw new DiggApiException("XML response appears to be malformed, or contains unexpected data.");
            }
            foreach (XmlNode node in xml_doc.SelectSingleNode("containers").SelectNodes("container")) {
                _containers.Add(new DiggContainer(node));
            }
        }

        public IEnumerator GetEnumerator()
        {
            return _containers.GetEnumerator();
        }
    }
}
